cmake_minimum_required(VERSION 3.10)
project(MyProject)
 
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
 
# 指定交叉编译工具链路径
set(tools /work/bsp/rk356x/buildroot/output/rockchip_rk3568/host/bin)
set(CMAKE_C_COMPILER ${tools}/aarch64-buildroot-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER ${tools}/aarch64-buildroot-linux-gnu-g++)

# 关键：跳过编译器测试
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
# 设置目标架构（关键！）
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv8-a")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=armv8-a")

## 保存工程路径
set(PROJECT_PATH ${CMAKE_CURRENT_SOURCE_DIR})

## 第三方库路径
set(THIRD_LIBS_PATH ${PROJECT_PATH}/libs)

## add include 
include_directories(${THIRD_LIBS_PATH}/ftd2xx/include)

## add dir
link_directories(
    ${THIRD_LIBS_PATH}/ftd2xx/lib
)
 
add_executable(my_app app/config.c)

target_link_libraries(my_app
    ${THIRD_LIBS_PATH}/ftd2xx/lib/libftd2xx-static.a
    pthread
)

include_directories(${PROJECT_PATH}/src)

file( GLOB header_list ${PROJECT_PATH}/src/*.h )
message(${header_list})

# add .cpp文件
file( GLOB source_list ${PROJECT_PATH}/src/*.cpp )

add_executable(read_data app/main.cpp ${source_list} ${header_list})

target_link_libraries(read_data 
    ${THIRD_LIBS_PATH}/ftd2xx/lib/libftd2xx-static.a
    pthread
)